package com.meyou.javascript.rewriter;

import java.util.ArrayList;
import java.util.List;

public class RewriteRegistry {
	
	public static final String ANY = "*";
	
	private List<RegistryEntry> registry = new ArrayList<RegistryEntry>();
	
	public RewriteRegistry()
	{
		super();
	}
	
	public void addEntry(String type, String call)
	{
		RegistryEntry entry = new RegistryEntry(type, call);
		registry.add(entry);
	}
	
	public boolean containsEntry(String type, String call)
	{
		for (RegistryEntry entry : registry)
		{
			if ((entry.type.equals(type)) && (entry.call.equals(call)))
				return true;
			
			if (entry.type.equals(ANY) && (entry.call.equals(call)))
				return true;
			
			if ((entry.type.equals(type)) && (entry.call.equals(ANY)))
				return true;
		}
		
		return false;
	}
	
}

class RegistryEntry {
	
	String type;
	String call;
	
	RegistryEntry(String type, String call)
	{
		this.type = type;
		this.call = call;
	}
	
}
